[CLI][Multi ASIC] Allow commands that don't support "-n" option to be run with "sudo ip netns.." option. #5446
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
- Why I did it
In multi ASIC platforms, CLIs commands can be under a namespace using the following command, which is now broken.
NOTE: CLI commands that support "-n" option will still give an error when run with "sudo ip netns exec ... " option. This behavior is intended to encourage users to use "-n" option.
The preferred way of running a CLI command for a namespace is using "-n" option of the CLI command. At this point not all 'show' CLIs have the support of specifying "-n" option. "sudo ip netns exec asicX" is the only way run a command for a namespace.
- How I did it
The command was failing as it was trying to connect to DB in different namespace. Made change so that get namespace API returns the current namespace if it is run under a non default namespace.
- How to verify it
Verified manually on multi ASIC platform.
Before:
After:
- Which release branch to backport (provide reason below if selected)
- Description for the changelog
Update get_all_linux_namespaces() API to return the current namespace
- A picture of a cute animal (not mandatory but encouraged)